//
//  ViewController.m
//  11105
//
//  Created by student on 16/3/1.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

 
@property (weak, nonatomic) IBOutlet UIScrollView *ScrollerView;
@property (nonatomic,assign) int x;
@property (nonatomic,assign) int y;
- (IBAction)upRightBtn:(id)sender;
- (IBAction)upBtn:(id)sender;
- (IBAction)upLeftBtn:(id)sender;
- (IBAction)leftBtn:(id)sender;
- (IBAction)downLeftBtn:(id)sender;
- (IBAction)downBtn:(id)sender;
- (IBAction)downRightBtn:(id)sender;
- (IBAction)RightBtn:(id)sender;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIImage *image = [UIImage imageNamed:@"bg"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    imageView.frame = CGRectMake(0, 0, 1600, 1000);
    
    self.ScrollerView.scrollEnabled = NO;
    [self.ScrollerView addSubview:imageView];
    self.ScrollerView.contentSize = CGSizeMake(1600,1000);
    self.x = self.ScrollerView.contentOffset.x;
    self.y = self.ScrollerView.contentOffset.y;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)upRightBtn:(id)sender {
    if(self.y>0)
    {
        self.ScrollerView.contentOffset = CGPointMake(self.x+=20, self.y-=20);
    }
}

- (IBAction)upBtn:(id)sender {
    if(self.y>0)
    {
        self.ScrollerView.contentOffset = CGPointMake(self.x, self.y-=20);
    }

}

- (IBAction)upLeftBtn:(id)sender {
    if(self.x>0 && self.y>0)
    {
        self.ScrollerView.contentOffset = CGPointMake(self.x-=20, self.y-=20);
    }
}


- (IBAction)leftBtn:(id)sender {
    if(self.x>0)
    {
        
        self.ScrollerView.contentOffset = CGPointMake(self.x-=20, self.y);
    }

}

- (IBAction)downLeftBtn:(id)sender {
    if(self.x>0 && self.y<1000-580)
    {
        
        self.ScrollerView.contentOffset = CGPointMake(self.x-=20, self.y+=20);
    }

}

- (IBAction)downBtn:(id)sender {
    if(self.y<1000-580)
    {
        self.ScrollerView.contentOffset = CGPointMake(self.x, self.y+=20);
    }

}

- (IBAction)downRightBtn:(id)sender {
    if(self.x+20<1600 && self.y<1000-580)
    {
        self.ScrollerView.contentOffset = CGPointMake(self.x+=20, self.y+=20);
    }

}

- (IBAction)RightBtn:(id)sender {
    if(self.x<1600)
    {
        self.ScrollerView.contentOffset = CGPointMake(self.x+=20, self.y);
    }

}
@end
